package com.example.ui_view;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.ui_view.model.Student;
import com.example.ui_view.model.user;

import java.util.ArrayList;

public class Test1Activity extends AppCompatActivity {
    Button btn_go;
    EditText et_id,et_name,et_class;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test1);
        btn_go = findViewById(R.id.btn_go);
        et_id = findViewById(R.id.et_id);
        et_name = findViewById(R.id.et_name);
        et_class = findViewById(R.id.et_class);
        btn_go.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Test1Activity.this,Test2Activity.class);
                Bundle bundle = new Bundle();
                if(!et_id.getText().toString().equals("")&&!et_name.getText().toString()
                        .equals("")&&!et_class.getText().toString().equals("")){
                    bundle.putString("et_id",et_id.getText().toString());
                    bundle.putString("et_name",et_name.getText().toString());
                    bundle.putString("et_class",et_class.getText().toString());
                    user user1 = new user("1001","zhangsan");
                    Student stu1 = new Student("10001","zhangsan");
                    Student stu2 = new Student("10002","lisi");
                    Student stu3 = new Student("10003","wangwu");

                    ArrayList<Student> arrayList_Stu = new ArrayList<>();
                    arrayList_Stu.add(stu1);
                    arrayList_Stu.add(stu2);
                    arrayList_Stu.add(stu3);

                    String[] arrstring = new String[]{"aaaa","bbbb","cccc"};
                    ArrayList<String>  arrayList = new ArrayList<>();
                    arrayList.add("1111");
                    arrayList.add("2222");
                    arrayList.add("3333");

                    bundle.putStringArrayList("arrlist_key",arrayList);
                    bundle.putSerializable("user_key",user1);
                    bundle.putStringArray("string_arr",arrstring);
                    bundle.putParcelableArrayList("arrayList_Stu", arrayList_Stu);
                    intent.putExtras(bundle);
                    startActivity(intent);
                }else {
                    Toast.makeText(Test1Activity.this,"信息还未输入完全！",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
